package com.me.memorytest;

import com.badlogic.gdx.Game;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.me.enums.ScreenEnum;
import com.me.helper.MySkin;
import com.me.screen.BaseScreen;
import com.me.screen.ScreenManager;

public class MainMemoryTest extends Game {
	private static ScreenManager screenManger;
	public static MySkin mySkin;
	public static TextureAtlas atlas;
	public static IAndroidAPI api;
	Image screenBg;
	@SuppressWarnings("unused")
	private IActivityRequestHandler myRequestHandler;
	
	@SuppressWarnings("static-access")
	public MainMemoryTest(IActivityRequestHandler handle, IAndroidAPI api){
		this.myRequestHandler = handle;
		this.api = api;
	}
	
	@Override
	public void create() {
		screenManger = new ScreenManager();
		screenBg = new Image(new Texture(Gdx.files.internal("data/loading/bg_black.png")));
		screenBg.setX(0);
		screenBg.setY(0);
		setScreen(screenManger.createScreen(ScreenEnum.LOADING_SCREEN));
		
		BaseScreen.stage = new Stage();
		BaseScreen.stage.addActor(screenBg);
	}

	public static IAndroidAPI getApi() {
		return api;
	}

	@Override
	public void render() {
		if (screenManger.getScreen() != null)
			screenManger.getScreen().render(Gdx.graphics.getDeltaTime());
		
		BaseScreen.stage.act();
		BaseScreen.stage.draw();
	}

	@Override
	public void resize(int width, int height) {
		super.resize(width, height);
		width = 1280 * width / height;
		height = 720;
		BaseScreen.stage.setViewport(width, height, false);

		// Make the background fill the screen
		screenBg.setSize(width, height);
	}

	@Override
	public void pause() {

	}

	@Override
	public void resume() {

	}

	public static TextureAtlas getAtlas() {
		return atlas;
	}

	public static MySkin getMySkin() {
		return mySkin;
	}

	public static ScreenManager getScreenManager() {
		return screenManger;
	}
}
